package com.tl.bootmeter.mapper;

import com.tl.bootmeter.pojo.MeterValue;
import com.tl.bootmeter.pojo.WellMeter;
import com.tl.bootmeter.pojo.WellMeterValue;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MeterValueMapper {

    //根据井号新增仪表基础信息（中间表也需要做好添加）
    @Insert("insert into meter_value values(#{meter_id},#{meter_number},#{meter_name},#{meter_manufactor},#{meter_network_type},#{meter_creat_time})")
    int insertByMeterValue(MeterValue meterValue);

    //中间表新增
    @Insert("insert into WELL_METER values(#{well_nanber},#{meter_sn},#{well_location})")
    int insertByWellMeter(WellMeter wellMetter);

    //根据仪表编号查询meter_value表中是否已有数据信息存在
    @Select("select * from METER_VALUE where meter_number = #{meter_sn}")
    MeterValue selectMeterValueByMeterSn(String meter_sn);

    //根据井号插叙这个井下共有多少块表
    @Select("select emd.well_namber,mv.meter_number,er.well_location,mv.meter_name,mv.meter_manufactor,mv.meter_creat_time,mv.meter_network_type\n" +
            "\t\tfrom WELL_METER er,METER_VALUE mv,WELL_MODE emd \n" +
            "\t\twhere mv.meter_number=er.meter_sn and emd.well_namber = er.well_namber and emd.well_namber=#{well_namber}")
    List<WellMeterValue> selectBywellNamber(String well_namber);
}
